<script setup lang="ts">
import {useStore} from "@/store"
import {useRouter} from "vue-router"
import Pagination from "@/components/common/pagination.vue";
import HomeTabs from "@/views/home/components/homeTabs.vue";
const store = useStore()
const router = useRouter()
function toDetail(item:any){
  let {id} = item
  router.push({path:`/roomDetail/${id}`})
  store.commit('setRoomId',id)
  console.log(item)
}
function changePage(pageNo:number){
  console.log('父组件',pageNo)
  store.dispatch('getRoomList',{pageNo})
}
</script>
<template>
  <!--      城市筛选-->
  <HomeTabs></HomeTabs>
<!--  首页列表数据-->
  <div class="home-list">
    <div class="item" @click="toDetail(item)" v-for="(item,index) in store.state.roomList" :key="index">
      <img :src="item.pictureUrl" :alt="item.title">
      <p class="title">{{item.title}}</p>
      <p class="price">￥{{item.price}}元</p>
    </div>
  </div>
  <!--      分页-->
  <Pagination @changePage="changePage"></Pagination>

</template>



<style scoped>

</style>